<?php

/*
    This autoloader is intentionally written in this manner.
*/

spl_autoload_register(function ($class) {
    if (class_exists($class, false)) {
        return true;
    }
    
    $name = strtr("$class", '\\', '/');
    if (!preg_match('~^[_a-zA-Z][_a-zA-Z0-9]*(?:/[_a-zA-Z][_a-zA-Z0-9]*)*$~', $name)) {
        return false;
    }
    
    $path = dirname(__DIR__) . "/classes/{$name}.php";
    if (is_file($path) && is_readable($path)) {
        require_once $path;
    } else {
        return false;
    }
    
}, true, true);


// vim: ts=4 et ai

